package com.realtyManage.springboot.Dao;


import com.realtyManage.springboot.Model.Do.Announcement;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface AnnouncementRepository extends JpaRepository<Announcement, Integer>, JpaSpecificationExecutor<Announcement> {

    @Query(value = "select * from announcement where type = :type and state = :state order by id desc limit 0,20", nativeQuery = true)
    List<Announcement> findByStateAndTypeGreaterThanEqualLimit(@Param("state")int state, @Param("type")int type);

    List<Announcement> findByStateAndType(int state, int type);
}
